import { RootState } from "../utils/store.type";
import { Module } from "vuex";

interface BaseState {
	aircraftStateConstant: string;
	isAircraftConnected: boolean;
	isRemoteControllerConnected: boolean;
	nestStateConstant: string;
}

const baseStatus: Module<BaseState, RootState> = {
	namespaced: true,
	state: () => ({
		aircraftStateConstant: "UNKNOWN",
		isAircraftConnected: false,
		isRemoteControllerConnected: false,
		nestStateConstant: "ERROR",
	}),

	mutations: {
		updatebasestate(state, payload) {
			// console.log(state,payload);
			const json = JSON.parse(payload);
			Object.assign(state, json);
		},
	},

	getters: {
		getStatus(state) {
			return state;
		},
	},

};

export 	default baseStatus;
